package com.rachel.studyapp.activity;

import android.os.Bundle;
import android.support.design.widget.CollapsingToolbarLayout;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;

import com.rachel.commonsdk.glide.GlideManager;
import com.rachel.studyapp.R;

public class HistoryDetailActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        String iconurl = getIntent().getStringExtra("url");
        String title = getIntent().getStringExtra("title");
        String content = getIntent().getStringExtra("content");
        Toolbar toolbar = (Toolbar) findViewById(R.id.his_detial_toorbar);
        setSupportActionBar(toolbar);
        ActionBar actionBar = getSupportActionBar();
        if (actionBar != null){
            //默认就是返回图标
            actionBar.setDisplayHomeAsUpEnabled(true);
        }

        ImageView imageView = (ImageView) findViewById(R.id.his_detial_icon);
        TextView textView = (TextView) findViewById(R.id.his_detail_text);
        textView.setText(content);
        new GlideManager.Builder()
                .setContext(this)
                .setTargetSource(iconurl)
                .setImageView(imageView)
                .setErrorBitmap(R.mipmap.setting_rank_nosignal)
                .builder();

        //设置滚动的文字
        CollapsingToolbarLayout collapsingToolbarLayout =
                (CollapsingToolbarLayout) findViewById(R.id.his_detial_collaps);
        collapsingToolbarLayout.setCollapsedTitleTextAppearance(R.style.Toolbar_TitleText);
        collapsingToolbarLayout.setTitle(title);
    }

    @Override
    public int getLayoutId() {
        return R.layout.activity_history_detail;
    }


    @Override
    public boolean onOptionsItemSelected(MenuItem item) {

        if (item.getItemId() == android.R.id.home){
            finish();
        }
        return true;
    }
}
